USE [BMIG_Mensual_POST_CADENA]
GO

/****** Object:  StoredProcedure [dbo].[WASP_M0004_CRED_SIN_TASA]    Script Date: 11/25/2011 11:55:13 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[WASP_M0004_CRED_SIN_TASA]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[WASP_M0004_CRED_SIN_TASA]
GO

USE [BMIG_Mensual_POST_CADENA]
GO

/****** Object:  StoredProcedure [dbo].[WASP_M0004_CRED_SIN_TASA]    Script Date: 11/25/2011 11:55:13 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO


CREATE PROCEDURE [dbo].[WASP_M0004_CRED_SIN_TASA] 

AS
BEGIN
SELECT 
	SUC,
	CRCREDITO,
	RUTTRABAJA,
	FNACITRABA,
	SEXOTRABAJ,
	CRMONTO,
	CRCUOTAS,
	cast(convert(float,round(max(b.aotasa),4)) as varchar)  as AUXTASA,
	--'000' + substring(convert(char , max(b.aotasa)),1,1)  + substring(convert(char , max(b.aotasa)),3,2) +  '00'  as  AUXTASA, 
	CRCLASE,
	CRFECAPROB,
	TIPO_TRABAJADOR

INTO dbo.AS_CREDI_VIGENTE_SINTASA
FROM 
	dbo.as_credi_vigente_temp AS  A, 
	FSD010 AS B
WHERE 
	SUBSTRING(RUTTRABAJA,1,LEN(RUTTRABAJA)-1) = AOCTA AND
	CRCREDITO=AOOPER AND 
	SUC = AOSUC AND AOSBOP = 0

GROUP BY 
	SUC,
	CRCREDITO,
	RUTTRABAJA,
	FNACITRABA,
	SEXOTRABAJ,
	CRMONTO,
	CRCUOTAS,
	CRCLASE,
	CRFECAPROB,
	TIPO_TRABAJADOR
END

GO


